package com.example.waibao.service.impl;

//import com.example.sannong.mapper.aaaMapper;
import com.example.waibao.dao.UserMapper;
import com.example.waibao.entity.*;
import com.example.waibao.mapper.userMapper2;
import com.example.waibao.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

//    @Autowired
//    private aaaMapper aaaMapper;

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private userMapper2 userMapper2;

    @Override
    public List<authority> get_all_authority() {

        return userMapper.get_all_authority();
    }

    @Override
    public void delete_student(int userId) {
        userMapper.delete_student(userId);
    }

    @Override
    public student get_a_student(int userId) {
        return userMapper.get_a_student(userId);
    }

    @Override
    public void add_teacher(User user) {
        userMapper.add_teacher(user);
    }

    @Override
    public PageInfo<User> get_users(Integer pageNum, Integer pageSize,int status,int school_id, String nick_name) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> f = userMapper2.get_users(status,school_id,nick_name);
        PageInfo<User> dataPageInfo = new PageInfo<>(f);
        return dataPageInfo;
    }

    @Override
    public List<school> get_school() {
        return userMapper.get_school();
    }

    @Override
    public void solve_users(Long id) {
        userMapper.solve_users(id);
    }

    @Override
    public void delete_users(Long id) {
        userMapper.delete_users(id);
    }

    @Override
    public PageInfo<student> get_all_student(Integer pageNum, Integer pageSize, int schoolId, String name) {
        PageHelper.startPage(pageNum,pageSize);
        List<student> f = userMapper2.get_all_student(schoolId,name);
        PageInfo<student> dataPageInfo = new PageInfo<>(f);
        return dataPageInfo;
    }

    @Override
    public void set_student_authority(int userId) {
        userMapper.set_student_authority(userId);
    }

    @Override
    public void school_register(school school) {
        userMapper2.school_register(school);
       // userMapper.school_register(school);
    }

//    @Override
//    public void set_speciality(int schoolId, String s) {
//       // userMapper.set_speciality(schoolId,s);
//        int id = userMapper2.set_speciality(schoolId,s);
//        System.out.println(id);
//    }

    @Override
    public void set_speciality(a_speciality a_speciality) {
        // userMapper.set_speciality(schoolId,s);
       int i = userMapper2.set_speciality(a_speciality);
//        System.out.println(a_speciality.getId());
    }
    @Override
    public void set_user_authority(int userId) {
        userMapper.set_user_authority(userId);
    }

    @Override
    public List<a_speciality> get_speciality(int schoolId) {
        return userMapper.get_speciality(schoolId);
    }

    @Override
    public void set_speciality_rank(int id, Date date1, int schoolId) {
        userMapper.set_speciality_rank(id,date1,schoolId);
    }

    @Override
    public void update_a_user(User user) {
        userMapper.update_a_user(user);
    }

    @Override
    public String check_password(User user) {
      return userMapper.check_password(user);
    }

    @Override
    public boolean check_username_reappear(String userName,int school_id) {
        if(userMapper.check_username_reappear(userName,school_id)!=null){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public boolean check_school_reappear(String name) {
        if(userMapper.check_school_reappear(name)!=null){
            return false;
        }else {
            return true;
        }
    }

    @Override
    public void delete_student_authority(int userId) {
        userMapper.delete_student_authority(userId);
    }

    @Override
    public void delete_user_authority(int userId) {
        userMapper.delete_user_authority(userId);
    }

    @Override
    public void delete_speciality(int schoolId) {
        userMapper.delete_speciality(schoolId);
    }

    @Override
    public void delete_speciality_rank(int schoolId) {
        userMapper.delete_speciality_rank(schoolId);
    }

    @Override
    public void update_speciality(a_speciality speciality) {
        userMapper.update_speciality(speciality);
    }

    @Override
    public void add_a_admin(User user) {
        userMapper2.add_a_admin(user);
    }

    @Override
    public void set_authority(Long id) {
        userMapper.set_authority(id);
    }

    @Override
    public void set_sys_authority(int userId, int roleId) {
        userMapper.set_sys_authority(userId,roleId);
    }

    @Override
    public void update_user_type(int userId, int roleId) {
        userMapper.update_user_type(userId,roleId);
    }

    @Override
    public String check_head_have(int s) {
        return userMapper.check_head_have(s);
    }

    @Override
    public int get_a_school_id(int id2) {
        return userMapper.get_a_school_id(id2);
    }

    @Override
    public void delete_student_faq(int userId) {
        userMapper.delete_student_faq(userId);
    }


}
